
@extends('admin.layouts.header_other')
@section('title',"后台管理系统")
@section('content')

<div class="layui-tab-content">
    <div class="layui-tab-item layui-show">
        <form class="layui-form" action="">
            <div class="amin-content">
                <div class="layui-row layui-col-space15">

                    <div class="layui-col-md12">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">角色名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="title" lay-verify="required|title" autocomplete="off" placeholder="输入2到12位字母" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">状态</label>
                                <div class="layui-input-inline">
                                    <input type="radio" name="status" value="启用" title="启用" checked="">
                                    <input type="radio" name="status" value="关闭" title="关闭">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">排序</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="psort" lay-verify="required|title" autocomplete="off" placeholder="输入2到12位汉字" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">

                            <label class="layui-form-label">角色描述</label>
                            <div class="layui-input-block">
                                <textarea placeholder="请输入描述" class="layui-textarea" name="description"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">角色权限</label>
                            <div class="layui-input-block">

                                @foreach($menuList as $vo)
                                <fieldset class="layui-elem-field site-demo-button">
                                    <legend>{{$vo['title']}}</legend>
                                    <ul class="grid quick-link layui-this">
                                        @foreach($vo['childer'] as $v)
                                        <li class="layui-col-xs1"><input type="checkbox" name="like1[write]" lay-skin="primary" title="{{$v['title']}}" checked=""></li>
                                        @endforeach
                                    </ul>
                                </fieldset>
                                @endforeach
                            </div>

                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="add_role">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<script src="{{asset('attach/js/layui.all.js')}}"></script>
<script>
    layui.use(['form'],function () {
        var form = layui.form;
        form.on(submit(add_role),function (data) {
            var index = parent.layer.getFrameIndex(window.name);
            var url = "{{route('admin.role.saveData')}}",
                data=$(data.form).serialize();
            $.ajax({
                type:'POST',
                url:url,
                data:data,
                success:function (data) {
                    if(data.code==200){
                        layer.msg(data.msg,{icon:6,time:2000},function () {
                            window.parent.location.reload();//刷新父页面
                            parent.layer.close(index);//关闭弹出层
                        });
                    }else{
                        layer.msg(data.msg,{icon:5});
                        return;
                    }
                }
            });
            return false;
        })

    });

</script>
@endsection
